	@include('user.head')
	<!-- 公共头部 -->

	<div id="content_denglu">
		<div class="denglu_in">
			<form class="form-horizontal">
			  <fieldset>
			    <legend class="legend_size">登陆 <span class="t_zhuce">还没有账号？<a href="<%url('regist')%>">注册</a></span></legend>
			    <div class="form-group">
			      <label for="uname" class="col-xs-2 control-label label_size">手机/邮箱</label>
			      <div class="col-xs-8">
			        <input class="form-control" name="username" id="username" placeholder="手机/邮箱账号" type="text">
			        <span class="hint">
			        	<i class="fa fa-check-circle"></i> <span class="msg"></span>
			        </span>
			      </div>
			    </div>
			    <div class="form-group">
			      <label for="password" class="col-xs-2 control-label label_size">密码</label>
			      <div class="col-xs-8">
			        <input class="form-control" name="password" id="password" placeholder="登陆密码" type="password">
			        <span class="hint">
			        	<i class="fa fa-check-circle"></i> <span class="msg"></span>
			        </span>
			      </div>
			    </div>
			    <div class="form-group" @if (Session::get('errorTimes') < 3 ) style="display:none;" @endif>
			      <label for="inputEmail" class="col-xs-2 control-label label_size">验证码</label>
			      <div class="col-xs-8">
			        <input class="form-control" name="code" id="code" placeholder="验证码" type="text">
			        <img src="<%url('code/thumb')%>" alt="" onclick="this.src=this.src+'?'+Math.random()">
			      </div>
			      <label for="inputEmail" class="col-xs-2 control-label label_size"></label>
		          <div class="col-xs-10">
		      		<span class="hint">
		      			<i class="fa fa-check-circle"></i> <span class="msg"></span>
		      		</span>
		          </div>
			    </div>
			    <div class="form-group">
			      <div class="col-xs-10 col-xs-offset-2">
			        <button type="button" id="checkLogin" class="btn btn-primary btn_denglu">登陆</button>
			      </div>
			    </div>
			  </fieldset>
			</form>

		</div>

	</div>
	<!-- 公共底部 -->
	@include('user.footer')

	<!-- 公共底部 -->
</body>
	@include('user.common')
	<script type="text/javascript">
	function checkUname(){
		var obj = $('#username');
		var username = obj.val().trim();
		if(username == ''){
			obj.parents('.form-group').find('.fa').addClass('fa-times-circle').css({'color':'red'});
			obj.parents('.form-group').find('.msg').html('请输入账号').css({'color':'red'});
			obj.parents('.form-group').find('.hint').show();
			return false;
		}
		return true;
	}

	function checkPass(){
		var obj = $('#password');
		var password = obj.val().trim();
		if(password == ''){
			obj.parents('.form-group').find('.fa').addClass('fa-times-circle').css({'color':'red'});
			obj.parents('.form-group').find('.msg').html('请输入密码').css({'color':'red'});
			obj.parents('.form-group').find('.hint').show();
			return false;
		}
		return true;
	}


	$('#checkLogin').click(function(){
		if(!checkUname()){
			return false;
		}
		if(!checkPass()){
			return false;
		}
		var username = $('#username').val().trim();
		var password = $("#password").val().trim();
		var code = $("#code").val().trim();

		$.post('login/login',{
			username : username,
			password : encrypt(password),
			code : code
		},function(data){
			if(data.success){
				window.location.href="uc/profile";
			}else{
				error('', data.msg);
				setTimeout(function(){
					window.location.reload();
				},1000)
			}

		})


	})


	</script>
</html>



